package com.ndp.fb.rdb.db.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ndp.fb.rdb.api.RoleAuthorityRdbService;
import com.ndp.fb.rdb.db.DaoTemplate;
import com.ndp.fb.rdb.db.impl.mapper.DefaultRowMapper;
import com.ndp.fb.rdb.model.RoleAuthority;
import com.ndp.fb.util.SQLUtil;

import java.util.List;

/**
 * Created by elvisxiong on 7/8/15.
 */
@Service
public class RoleAuthorityRdbServiceImpl extends DaoTemplate implements RoleAuthorityRdbService {
    @Override
    public List<RoleAuthority> getRoleAuthorityByRole(List<Long> roleIds) {
        String sql = "SELECT * FROM role_authority WHERE role_id IN (" + SQLUtil.appendPlaceholder(roleIds.size()) + ")";
        return getJdbcTemplate().query(sql, roleIds.toArray(), DefaultRowMapper.autoRowMapper(RoleAuthority.class));
    }
}
